<?php echo $this->render($this->includeDir . '/toolbar.php');?>
<?php echo $this->flashMessage();?>
<?php 
	$arrParam = $this->arrParam;
	
	$name 		= $this->formText('name',$this->Item['name'],array('class'=>'width-300 bg-green2 floatLeft' ));
	
	$parentValue = $this->Item['parents']>0?$this->Item['parents']:1;
	$parents	= $this->cmsSelect('parents', $parentValue,array('class'=>'width-150','size'=>10), $this->slbParents);

	$options 	= array('router'=>' Link ','article'=>' Article ');	
	$router 	= $this->formSelect('router',$this->Item['type'],array('class'=>'width-150'),$options);

	$image	= $this->formFile('image',array('class'=>'floatLeft' ));
	if($this->arrParam['action'] == 'edit'){
		$config = new Zendvn_Controller_Config(array('module'=>$arrParam['module'],
												'fileConfig'=>'news-category.ini'));
	 	
	 	$imageConfig = $config->getConfig('category');
		
		$current_image = '<div id="load-content-image" class="clr width-150 center">';
		if(!empty($this->Item['image'])){
			$imageUrl = $imageConfig['thumbUrl'] . '/' . $this->Item['image'];
			$removeLink = $this->url(array('action'=>'remove-pic','type'=>'image','file'=>$this->Item['image']));
			$current_image .= '<br>' . $this->cmsImage('image',$imageUrl,array('width'=>'75px'))
							. '<br><a  class="remove" href="javascript:loadPage(\'div#load-content-image\',\'' . $removeLink . '\')">remove</a>';
		}
		
		$current_image .= $this->formHidden('current_image',$this->Item['image'])
						. '</div>';
		$image .=	$current_image;		
	}
	
	$options 	= array('inactive'=>$this->translate('Inactive'),'active'=>$this->translate('Active'));	
	$status 	= $this->formSelect('status',$this->Item['status'],array('class'=>'width-150'),$options);

	$description 		= Zendvn_Filter_Filter::filterContent($this->Item['description'],'filter');
	$description		= $this->tinyMce('description',$description,array('style'=>"width: 100%; height: 250px;"));
	$description		= '<div id="d_description" style="width:98%; float: left">' . $description . '</div>';
	$html_descript = $this->formTextarea('html_descript',$this->Item['html_descript'],array('class'=>'width-400','rows'=>8));
	
	$html_keyword = $this->formTextarea('html_keyword',$this->Item['html_keyword'],array('class'=>'width-400','rows'=>8));
	$formHelp = '';
	$config = new Zendvn_Controller_Config(array('module'=>$arrParam['module'],
												'fileConfig'=>'news-category.ini',
												'section'=>'tooltip'));
	$arrTooltip = $config->getConfig('category');
	if(count($arrTooltip)>0){
		foreach ($arrTooltip as $key => $val){
			$attribs = array();
			if($key=='d_description') $attribs = array('leftOffset'=>-305);
			$formHelp  .= $this->cmsFormHelp('.form-table #' . $key, $this->translate($val), $attribs);
		}
	}
		
	 if(count($this->errors)>0){	
	 	foreach ($this->errors as $key => $val){	 		
	 		$$key .= $this->cmsError($key,$val);	
	 		$selector = '.form-table #' . $key . '-error';
	 		$options = array('type'=>'error','name'=>'#' .$key);
	 		$formHelp  .= $this->cmsFormHelp($selector, $this->translate($val),null,$options);
	 		
	 	}
	 }
	$arrRow = array(
						array('label'=>$this->translate('Name'),'input'=>$name),	
						array('label'=>$this->translate('Type'),'input'=>$router),	
						array('label'=>$this->translate('Parent'),'input'=>$parents),
						array('label'=>$this->translate('Image'),'input'=>$image),								
						array('label'=>$this->translate('Description'),'input'=>$description),
						array('label'=>$this->translate('Html descript'),'input'=>$html_descript),
						array('label'=>$this->translate('Html keywords'),'input'=>$html_keyword),
						array('label'=>$this->translate('Status'),'input'=>$status),
					 );
	$tdForm = $this->partialLoop('row.php',$arrRow);
	
?>
<script type="text/javascript">
	$(document).ready(function() {
		<?php echo $formHelp;?>
	});
</script>
<div id="element-box">
	<div class="m">
		<div class="form-table">
            <fieldset class="admin-fieldset">
                <legend class="admin-legend"><?php echo $this->translate('Form detail')?></legend>
            	<table width="100%" border="0">
                	<?php echo $tdForm;?>
                </table>
                <div class="clr"></div>
			</fieldset>    
        </div>
            <div class="clr"></div>
	</div>
</div>
